package org.xxpay.core.service;

import com.alibaba.fastjson.JSONObject;
import org.xxpay.core.entity.MchAgentpayRecord;
import org.xxpay.core.entity.MchSettRecord;
import org.xxpay.core.entity.TransOrder;

import java.util.List;
import java.util.Map;

/**
 * @author: dingzhiwei
 * @date: 18/04/21
 * @description: 商户代付操作
 */
public interface IMchAgentpayService {

    /**
     * 冻结商户余额 & 对应实体对象入库操作
     * @param frozenAmount 申请代付总金额
     * @param recordList record列表
     * @return
     */
    void frozenAmountAndInsertRecord(Long frozenAmount, List<MchAgentpayRecord> recordList);

    /**
     * 更新代付状态为成功
     * @param agentpayOrderId
     * @return
     */
    void updateStatus4Success(String agentpayOrderId, String transOrderId, String channelOrderNo, boolean isTccard);

    /**
     * 更新代付状态为失败
     * @param agentpayOrderId
     * @return
     */
    void updateStatus4Fail(String agentpayOrderId, String transOrderId, String channelErrCode, String channelErrMsg, Byte recordOldStatus);


    /** 更新为处理中状态 **/
    void updateAudit2Ing(String agentpayOrderId, MchAgentpayRecord record);


        /**
         * 查询代付列表
         * @param offset
         * @param limit
         * @param mchAgentpayRecord
         * @return
         */
    List<MchAgentpayRecord> select(int offset, int limit, MchAgentpayRecord mchAgentpayRecord, JSONObject queryObj);

    /**
     * 查询个数
     * @param mchAgentpayRecord
     * @return
     */
    int count(MchAgentpayRecord mchAgentpayRecord, JSONObject queryObj);

    /**
     * 查询代付记录
     * @param mchAgentpayRecord
     * @return
     */
    MchAgentpayRecord find(MchAgentpayRecord mchAgentpayRecord);

    MchAgentpayRecord findByTransOrderId(String transOrderId);

    MchAgentpayRecord findByAgentpayOrderId(String agentpayOrderId);

    MchAgentpayRecord findByMchIdAndAgentpayOrderId(Long mchId, String agentpayOrderId);

    MchAgentpayRecord findByMchIdAndMchOrderNo(Long mchId, String mchOrderNo);

    List<MchAgentpayRecord> select(int offset, int limit, List<Byte> statusList, MchAgentpayRecord mchAgentpayRecord);

    int count(List<Byte> statusList, MchAgentpayRecord mchAgentpayRecord);

    Map count4All(Long mchId, Long supplierExecId, String accountName, String agentpayOrderId, String transOrderId, Byte status, Byte agentpayChannel, String mchOrderNo, String operatorUserId, String createTimeStart, String createTimeEnd);

    /**  **/
    int updateById(MchAgentpayRecord updateRecord);

    Integer count(MchAgentpayRecord mchAgentpayRecord);

    /** 抢单 **/
    Integer snatchOrder(String agentpayOrderId, String snatchUserId, String snatchName);

    /** 弃单 **/
    Integer giveUpOrder(String agentpayOrderId, String snatchUserId, boolean isSupAdmin);

    int updateMchConfirmResp(String agentpayOrderId, String resp);

    int updateStatus4WaitMchComfirmSuccess(String agentpayOrderId, Byte updateRecordStatus, TransOrder transOrder);

    /** 给补单提供的更新订单函数 **/
    int updateByReissue(String agentpayOrderId, Byte updateStatus);

    List<MchAgentpayRecord> selectList(List<String> idList);
}
